<template>
    <div class="p-detail-box" v-if="form">
        <!-- <van-swipe class="my-swipe" :autoplay="3000" indicator-color="white">
            <van-swipe-item v-for="(item, i) in zctpArr" :key="i">
                <van-image fit="fill" :src="item.fileUrl" />
            </van-swipe-item>
        </van-swipe> -->
        <!-- <div class="p-t-box bgfff">
            <div class="p-title" v-if="form.name">{{ form.name }}</div>
            <div class="addr-bg" v-if="(addressObj && addressObj.isShow) || (orgObj && orgObj.isShow)">
                <div class="p-addr" v-if="addressObj.isShow"><span class="color86">地址：</span> {{ addressObj.name }}</div>
                <div class="p-addr" v-if="orgObj.isShow"><span class="color86">管理单位：</span>{{ orgObj.name }}</div>
                <img src="../../assets/addr.png" v-if="addressObj.isShow" @click="viewMapClick" alt="" />
            </div>
            <div class="p-addr p-addr2 flex-cb">
                <span class="flex1" v-if="jzmjObj.isShow"><span class="color86">{{ jzmjObj?.name }}：</span>{{
                    form.countAmount
                    || '--' }}</span>
                <span class="flex1" v-if="jcnfObj.isShow && form.category === 0"><span class="color86">建成年份：</span>{{
                    jcnfObj.name }}</span>
            </div>
            <div class="p-addr p-addr2 flex-cb" v-if="form.category === 1">
                <span><span class="color86" v-if="form.houseOrlandDetailWebObj.landArea">土地面积：</span>{{ form.houseOrlandDetailWebObj.landArea || '--' }}m²</span>
            </div>
        </div> -->
        <!-- <div style="height: 20px;background: #fff;"></div> -->
        <van-nav-bar title="资产盘点" left-arrow @click-left="$router.back()" />
        <!-- {{ tabTit }} -->
        <van-tabs class="new-tabs-box" scrollable swipe-threshold="4">
            <van-tab v-for="(item, index) in tabTit" :title="item.title" :key="index">
                <van-form>
                    <div v-for="(child, j) in fieldList.filter((e) => {
                        if (e.name === item.title) return e
                    })[0].childList" class="item-box item-box1" :key="j">
                        <template v-if="item.title === '基本信息'">
                            <template v-if="child.code === 'jcxx' && child.isShow && !!child.display">
                                <div class="s-name">{{ child.name }}</div>
                                <div v-for="(c, g) in child.childList" :key="g" class="bb1">
                                    <van-field v-model="form.code" readonly :label="c.name"
                                        v-if="c.code === 'zcbm' && c.isShow && !!c.display" />
                                    <van-field v-model="form.orgName" readonly :label="c.name"
                                        v-if="c.code === 'gldw' && c.isShow && !!c.display" />
                                    <van-field v-model="form.projectName" readonly :label="c.name"
                                        v-if="c.code === 'ssxm' && c.isShow && !!c.display" />
                                    <van-field v-model="form.typeName" readonly :label="c.name"
                                        v-if="c.code === 'zclx' && c.isShow && !!c.display" />
                                    <van-field v-model="form.nodeName" readonly :label="c.name"
                                        v-if="c.code === 'zcwz' && c.isShow && !!c.display" />
                                    <van-field v-model="form.purposeNames" readonly :label="c.name"
                                        v-if="c.code === 'zcyt' && c.isShow && !!c.display" />
                                    <van-field v-model="form.relatedNames" readonly :label="c.name"
                                        v-if="c.code === 'glzc' && c.isShow && !!c.display" />
                                    <van-field v-model="form.remark" readonly :label="c.name"
                                        v-if="c.code === 'bz' && c.isShow && !!c.display" />
                                    <van-field v-model="form.userName" readonly :label="c.name"
                                        v-if="c.code === 'zcsyr' && c.isShow && !!c.display" />
                                    <van-field v-model="form.countAmount" readonly :label="c.name"
                                        v-if="c.code === 'tjsl' && c.isShow && !!c.display" />
                                    <van-field v-if="c.code === 'zctp' && c.isShow && !!c.display" class="disn" />
                                    <template v-if="+form.category === 0">
                                        <van-field v-model="form.houseOrlandDetailWebObj.houseNumber" readonly
                                            :label="c.name" v-if="c.code === 'fh' && c.isShow && !!c.display" />
                                        <!-- <van-field v-model="form.houseOrlandDetailWebObj.buildingArea" readonly :label="c.name" v-if="c.code === 'jzmj' && c.isShow" /> -->
                                    </template>
                                    <!-- <template v-if="+form.category === 1">
                                        <van-field v-model="form.houseOrlandDetailWebObj.landArea" readonly :label="c.name" v-if="c.code === 'tdmj' && c.isShow" />
                                    </template> -->
                                </div>
                                <ZdyView :zdyArryList="child.childList" :title="item.title" v-if="!!child.display" />
                            </template>
                            <template v-else-if="child.code === 'wzxx' && child.isShow && !!child.display">
                                <div class="s-name">{{ child.name }}</div>
                                <div v-for="(c, g) in child.childList" :key="g" class="bb1">
                                    <van-field v-model="form.coordinateAddress" readonly :label="c.name"
                                        v-if="c.code === 'xmdz' && c.isShow && !!c.display" />
                                    <van-field v-model="form.streetName" readonly :label="c.name"
                                        v-if="c.code === 'xmjddz' && c.isShow && !!c.display" />
                                    <van-field v-model="form.address" readonly :label="c.name"
                                        v-if="c.code === 'xmxxdz' && c.isShow && !!c.display" />
                                </div>
                                <ZdyView :zdyArryList="child.childList" :title="item.title" v-if="!!child.display" />
                            </template>
                            <template v-else-if="child.code === 'jzxx' && child.isShow && !!child.display">
                                <div class="s-name">{{ child.name }}</div>
                                <div v-for="(c, g) in child.childList" :key="g" class="bb1">
                                    <van-field v-model="form.houseOrlandDetailWebObj.builtYear" readonly :label="c.name"
                                        v-if="c.code === 'jcnf' && c.isShow && !!c.display" />
                                    <van-field
                                        :value="form.houseOrlandDetailWebObj.buildingStructure && form.optionMap && form.optionMap[form.houseOrlandDetailWebObj.buildingStructure]"
                                        readonly :label="c.name" v-if="c.code === 'jzjg' && c.isShow && !!c.display" />
                                    <van-field
                                        :value="[0, 1].includes(+form.houseOrlandDetailWebObj.dilapidated) ? (+form.houseOrlandDetailWebObj.dilapidated === 0 ? '否' : '是') : '--'"
                                        readonly :label="c.name" v-if="c.code === 'sfwf' && c.isShow && !!c.display" />
                                    <van-field
                                        :value="[0, 1].includes(+form.houseOrlandDetailWebObj.provisional) ? (+form.houseOrlandDetailWebObj.provisional === 0 ? '否' : '是') : '--'"
                                        readonly :label="c.name" v-if="c.code === 'sflj' && c.isShow && !!c.display" />
                                    <van-field v-model="form.houseOrlandDetailWebObj.contractorName" readonly
                                        :label="c.name" v-if="c.code === 'jzdw' && c.isShow && !!c.display" />
                                    <van-field
                                        :value="form.houseOrlandDetailWebObj.quality && form.optionMap && form.optionMap[form.houseOrlandDetailWebObj.quality]"
                                        readonly :label="c.name" v-if="c.code === 'fwzl' && c.isShow && !!c.display" />
                                </div>
                                <ZdyView :zdyArryList="child.childList" :title="item.title" v-if="!!child.display" />
                            </template>
                            <template v-else>
                                <div class="s-name" v-if="child.childList.length && !!child.display">{{ child.name }}</div>
                                <ZdyView :zdyArryList="child.childList" :title="item.title" v-if="!!child.display" />
                            </template>
                        </template>
                        <template v-else-if="item.title === '接收信息'">
                            <template v-if="child.code === 'lyxx' && child.isShow && !!child.display">
                                <div class="s-name">{{ child.name }}</div>
                                <div v-for="(c, g) in child.childList" :key="g" class="bb1">
                                    <van-field
                                        :value="form.acceptWebDto.sourceId && form.optionMap && form.optionMap[form.acceptWebDto.sourceId]"
                                        readonly :label="c.name" v-if="c.code === 'lylx' && c.isShow && !!c.display" />
                                    <van-field v-model="form.acceptWebDto.acquireDate" readonly :label="c.name"
                                        v-if="c.code === 'jzdw' && c.isShow && !!c.display" />
                                    <van-field v-model="form.acceptWebDto.unitName" readonly :label="c.name"
                                        v-if="c.code === 'yjdw' && c.isShow && !!c.display" />
                                    <van-field v-model="form.acceptWebDto.acquireArea" readonly :label="c.name"
                                        v-if="c.code === 'jssmj' && c.isShow && !!c.display" />
                                </div>
                                <ZdyView :zdyArryList="child.childList" :title="item.title" v-if="!!child.display" />
                            </template>
                            <template v-else-if="child.code === 'xgfj'">
                            </template>
                            <template v-else>
                                <div class="s-name" v-if="child.childList.length && !!child.display">{{ child.name }}</div>
                                <ZdyView :zdyArryList="child.childList" :title="item.title" v-if="!!child.display" />
                            </template>
                        </template>
                        <template v-else-if="item.title === '价值信息'">
                            <template v-if="child.code === 'jzxx' && child.isShow && !!child.display">
                                <div class="s-name">{{ child.name }}</div>
                                <div v-for="(c, g) in child.childList" :key="g" class="bb1">
                                    <van-field v-model="form.valueWebDto.price" readonly :label="c.name"
                                        v-if="c.code === 'zcjz' && c.isShow && !!c.display" />
                                    <van-field v-model="form.valueWebDto.unitPrice" readonly :label="c.name"
                                        v-if="c.code === 'zcdj' && c.isShow && !!c.display" />
                                    <van-field v-model="form.valueWebDto.postDate" readonly :label="c.name"
                                        v-if="c.code === 'rzrq' && c.isShow && !!c.display" />
                                    <van-field v-model="form.valueWebDto.originalPrice" readonly :label="c.name"
                                        v-if="c.code === 'zmyz' && c.isShow && !!c.display" />
                                    <van-field v-model="form.valueWebDto.originalBasis" readonly :label="c.name"
                                        v-if="c.code === 'yzyj' && c.isShow && !!c.display" />
                                    <van-field
                                        :value="[0, 1].includes(+form.valueWebDto.onAccount) ? (+form.valueWebDto.onAccount === 0 ? '否' : '是') : '--'"
                                        readonly :label="c.name" v-if="c.code === 'sfzz' && c.isShow && !!c.display" />
                                    <van-field v-model="form.valueWebDto.onAccountUnit" readonly :label="c.name"
                                        v-if="c.code === 'zzdw' && c.isShow && !!c.display" />
                                    <van-field
                                        :value="form.valueWebDto.accountSubject && form.optionMap && form.optionMap[form.valueWebDto.accountSubject]"
                                        readonly :label="c.name" v-if="c.code === 'jzkm' && c.isShow && !!c.display" />
                                </div>
                                <ZdyView :zdyArryList="child.childList" :title="item.title" />
                            </template>
                            <template v-else>
                                <div class="s-name" v-if="child.childList.length && !!child.display">{{ child.name }}</div>
                                <ZdyView :zdyArryList="child.childList" :title="item.title" v-if="!!child.display" />
                            </template>
                        </template>
                        <template v-else-if="item.title === '产证信息'">
                            <template v-if="child.code === 'cqxx' && child.isShow && !!child.display">
                                <div class="s-name">{{ child.name }}</div>
                                <div v-for="(c, g) in child.childList" :key="g" class="bb1">
                                    <van-field
                                        :value="form.houseOrlandDetailWebObj.certificateWebDto.rightState === 2 ? '无证' : form.houseOrlandDetailWebObj.certificateWebDto.rightState === 1 ? '有证' : '未知'"
                                        readonly :label="c.name" v-if="c.code === 'cqqk' && c.isShow && !!c.display" />
                                    <van-field
                                        :value="form.houseOrlandDetailWebObj.certificateWebDto.rightIds && form.optionMap && form.optionMap[form.houseOrlandDetailWebObj.certificateWebDto.rightIds]"
                                        readonly :label="c.name" v-if="c.code === 'czqk' && c.isShow && !!c.display" />
                                    <van-field v-model="form.houseOrlandDetailWebObj.certificateWebDto.noRightReason"
                                        readonly :label="c.name" v-if="c.code === 'qzyy' && c.isShow && !!c.display" />
                                    <van-field v-model="form.houseOrlandDetailWebObj.certificateWebDto.rightUnitId" readonly
                                        :label="c.name" v-if="c.code === 'cqdw' && c.isShow && !!c.display" />
                                    <van-field v-model="form.houseOrlandDetailWebObj.certificateWebDto.landNumber" readonly
                                        :label="c.name" v-if="c.code === 'zdh' && c.isShow && !!c.display" />
                                    <van-field v-model="form.houseOrlandDetailWebObj.certificateWebDto.rightRatio" readonly
                                        :label="c.name" v-if="c.code === 'cqbl' && c.isShow && !!c.display" />
                                    <van-field
                                        :value="form.houseOrlandDetailWebObj.certificateWebDto.rightTypeId && form.optionMap && form.optionMap[form.houseOrlandDetailWebObj.certificateWebDto.rightTypeId]"
                                        readonly :label="c.name" v-if="c.code === 'cqlb' && c.isShow && !!c.display" />
                                    <van-field v-model="form.houseOrlandDetailWebObj.certificateWebDto.rightNumber" readonly
                                        :label="c.name" v-if="c.code === 'cqzh' && c.isShow && !!c.display" />
                                    <van-field v-model="form.houseOrlandDetailWebObj.certificateWebDto.identifyNumber"
                                        readonly :label="c.name" v-if="c.code === 'cjh' && c.isShow && !!c.display" />
                                    <van-field v-model="form.houseOrlandDetailWebObj.certificateWebDto.issuedDate" readonly
                                        :label="c.name" v-if="c.code === 'bzrq' && c.isShow && !!c.display" />
                                    <van-field v-model="form.houseOrlandDetailWebObj.certificateWebDto.houseBuildingArea"
                                        readonly :label="c.name" v-if="c.code === 'fwjzmjzj' && c.isShow && !!c.display" />
                                    <van-field v-model="form.houseOrlandDetailWebObj.certificateWebDto.parcelArea" readonly
                                        :label="c.name" v-if="c.code === 'zdmjzj' && c.isShow && !!c.display" />
                                    <van-field v-model="form.houseOrlandDetailWebObj.certificateWebDto.realEstateUnitNumber"
                                        readonly :label="c.name" v-if="c.code === 'bdcdyh' && c.isShow && !!c.display" />
                                </div>
                                <ZdyView :zdyArryList="child.childList" :title="item.title" />
                            </template>
                            <template v-else-if="child.code === 'dyxx' && child.isShow && !!child.display">
                                <div class="s-name">{{ child.name }}</div>
                                <div v-for="(c, g) in child.childList" :key="g" class="bb1">
                                    <van-field
                                        :value="[0, 1].includes(+form.houseOrlandDetailWebObj.certificateWebDto.mortgaged) ? (+form.houseOrlandDetailWebObj.certificateWebDto.mortgaged === 0 ? '否' : '是') : '--'"
                                        readonly :label="c.name" v-if="c.code === 'sfdy' && c.isShow && !!c.display" />
                                    <template v-if="+form.houseOrlandDetailWebObj.certificateWebDto.mortgaged === 1">
                                        <van-field v-model="form.houseOrlandDetailWebObj.certificateWebDto.mortgageeName"
                                            readonly :label="c.name" v-if="c.code === 'dyqr' && c.isShow && !!c.display" />
                                        <van-field v-model="form.houseOrlandDetailWebObj.certificateWebDto.mortgageAmount"
                                            readonly :label="c.name" v-if="c.code === 'dyje' && c.isShow && !!c.display" />
                                        <van-field
                                            v-model="form.houseOrlandDetailWebObj.certificateWebDto.mortgageBeginDate"
                                            readonly :label="c.name"
                                            v-if="c.code === 'dyksrq' && c.isShow && !!c.display" />
                                        <van-field v-model="form.houseOrlandDetailWebObj.certificateWebDto.mortgageEndDate"
                                            readonly :label="c.name"
                                            v-if="c.code === 'dyjsrq' && c.isShow && !!c.display" />
                                        <van-field
                                            :value="form.houseOrlandDetailWebObj.certificateWebDto.mortgageMethod && form.optionMap && form.optionMap[form.houseOrlandDetailWebObj.certificateWebDto.mortgageMethod]"
                                            readonly :label="c.name" v-if="c.code === 'dyfs' && c.isShow && !!c.display" />
                                        <van-field v-model="form.houseOrlandDetailWebObj.certificateWebDto.creditAmount"
                                            readonly :label="c.name"
                                            v-if="c.code === 'bdbzzqse' && c.isShow && !!c.display" />
                                        <van-field v-model="form.houseOrlandDetailWebObj.certificateWebDto.creditTopAmount"
                                            readonly :label="c.name"
                                            v-if="c.code === 'zgzqse' && c.isShow && !!c.display" />
                                    </template>
                                </div>
                                <ZdyView :zdyArryList="child.childList" :title="item.title" />
                            </template>
                            <template v-else-if="child.code === 'cqzj'">
                                <!-- <UploadFile :attachmentList="tableDataCQ" class="is-upload" /> -->
                            </template>
                            <template v-else>
                                <div class="s-name" v-if="child.childList.length && !!child.display">{{ child.name }}</div>
                                <ZdyView :zdyArryList="child.childList" :title="item.title" v-if="!!child.display" />
                            </template>
                        </template>
                        <template v-else-if="item.title === '经营信息'">
                            <template v-if="child.code === 'jyxx' && child.isShow && !!child.display">
                                <div class="s-name">{{ child.name }}</div>
                                <div v-for="(c, g) in child.childList" :key="g" class=" bb2">
                                    <van-field style="padding: 12px !important;"
                                        :value="[0, 1].includes(+form.houseOrlandDetailWebObj.operateWebDto.planned) ? (+form.houseOrlandDetailWebObj.operateWebDto.planned === 0 ? '否' : '是') : '--'"
                                        readonly :label="c.name" v-if="c.code === 'sfwczcgh' && c.isShow && !!c.display" />
                                </div>
                                <ZdyView :zdyArryList="child.childList" :title="item.title" v-if="!!child.display" />
                            </template>
                            <template v-else>
                                <div class="s-name" v-if="child.childList.length && !!child.display">{{ child.name }}</div>
                                <ZdyView :zdyArryList="child.childList" :title="item.title" v-if="!!child.display" />
                            </template>
                        </template>
                        <!-- 自定义展示 -->
                        <template v-else>
                            <div class="s-name" v-if="!!child.display">{{ child.name }}</div>
                            <ZdyView :zdyArryList="child.childList" :title="item.title" v-if="!!child.display" />
                        </template>
                    </div>
                </van-form>
            </van-tab>
        </van-tabs>

        <van-popup v-model="mapShow">
            <positionMap v-if="form.positionType === 1" ref="positionMap" :initialPosition="initialPosition" />
            <gaoDeMap v-if="form.positionType === 2" ref="positionMap" :initialPosition="initialPosition" />
        </van-popup>
    </div>
</template>

<script>
import backMixin from '../../mixins/backMixin'
import BaiduMap from 'vue-baidu-map'
import positionMap from '@/components/positionMap'
import UploadFile from '@/components/uploadFile'
import ZdyView from './zdy.vue'
import dayjs from 'dayjs'
import Vue from 'vue'
import { BaiduGaoDeLngLatConvert, isPlusEnv } from '@/utils/utils'
export default {
    mixins: [backMixin],
    name: 'pmd',
    data() {
        return {
            mapShow: false,
            form: null,
            initialPosition: {}, // 经纬度
            mapObj: {
                point: {}
            }, // 地图的经纬度
            addressObj: {
                name: '',
                isShow: false
            },
            orgObj: {
                name: '',
                isShow: false
            },
            jzmjObj: {
                name: '',
                isShow: false
            },
            jcnfObj: {
                name: '',
                isShow: false
            },
            ruleFormAdd: {},
            tableDataCQ: [], // 产权附件
            tableData: [], // 相关附件
            // zctpArr: [ {fileUrl: 'https://img0.baidu.com/it/u=987660757,2239835019&fm=253&fmt=auto&app=138&f=JPEG?w=256&h=256'}], // 顶部图片
            zctpArr: [], // 顶部图片
            tabTit: [],
            optionsCQZJ: [],
            fieldList: [],
            eventData: [],
            customizeList: [],
            projectTreeData: [],
            isAPP: false,
            hasMatchingNodeId: false,
            baseInfoList: []
        }
    },
    components: {
        UploadFile,
        ZdyView,
        positionMap
    },
    computed: {
        mapConfig() {
            return this.$store.state.baseData.mapConfig
        }
    },
    watch: {},
    created() {
        this.isAPP = isPlusEnv() || false
    },
    mounted() {
       this.__init()
    },
    methods: {
        __dayjs(val) {
            if (!val) return ''
            return dayjs(new Date(+val)).format('YYYY-MM-DD')
        },
        async __init() {
            let id = this.$route.query.k
            if (this.isAPP) {
                let orgId = this.$route.query.orgId
                let memberId = this.$route.query.memberId
                localStorage.XUserToken = this.$route.query.XUserToken
                const resToken = await this.$Geting(this.$api.getTokenByAppServiceId, {
                    appServiceId: 'property',
                    orgId,
                    memberId
                });
                if (resToken.isSuccess) {
                    sessionStorage.accessToken = resToken.data.accessToken
                    await this.__getOrgProjectTree()
                    this.__getDetialData(id)
                }
            } else {
                this.__getDetialData(id)
            }
        },
        // 获取楼盘项目树
        async __getOrgProjectTree() {
            try {
                const res = await this.$Geting(this.$api.getAssetsTree)
                if (res.code === '0') {
                    let resData = res.data.treeData || {}
                    this.projectTreeData = resData ? [resData] : []
                }
            } catch (error) {
                console.error('获取楼盘项目树出错:', error)
            }
        },
        // 动态获取百度地图的ak
        async queryMessage(tenantId) {
            let res = await this.$Geting(this.$api.getMapBaiDu + '?tenantId=' + tenantId)
            if (res.isSuccess) {
                let resData = res.data
                let { jsKey } = resData
                this.$ak = jsKey
                this.$store.commit('setMapConfig', resData)
                Vue.use(BaiduMap, { ak: jsKey })
            }
        },
        // 获取目录列表
        async __getFileList(d2, arr, customizeList, status) {
            console.log('字段列表数据:', arr)
            this.tabTit = []
            d2.forEach((e, i) => {
                if (e.childList && e.childList.length) {
                    e.childList.forEach((c) => {
                        if (c.childList && c.childList.length) {
                            c.childList.forEach((cc) => {
                                if (arr.length) {
                                    cc.isShow = false
                                    arr.forEach((a) => {
                                        if (cc.customize) {
                                            if (cc.fieldRule.descPath === a.fieldKeyPath) {
                                                cc.isShow = true
                                            }
                                        } else {
                                            if (cc.path === a.fieldKeyPath) {
                                                cc.isShow = true
                                            }
                                        }
                                    })
                                } else {
                                    cc.isShow = status || cc.display
                                }
                                if (cc.code === 'gldw') {
                                    this.orgObj = {
                                        name: '',
                                        isShow: cc.isShow || cc.display
                                    }
                                }
                                if (cc.code === 'tjsl') {
                                    this.jzmjObj = {
                                        name: cc.name,
                                        isShow: cc.isShow || cc.display
                                    }
                                }
                                if (cc.code === 'xmxxdz') {
                                    this.addressObj = {
                                        name: '',
                                        isShow: cc.isShow || cc.display
                                    }
                                }
                                if (cc.code === 'jcnf') {
                                    this.jcnfObj = {
                                        name: '',
                                        isShow: cc.isShow || cc.display
                                    }
                                }
                            })
                        }
                    })
                }
            })
            customizeList.length &&
                customizeList.forEach((e, i) => {
                    if (arr.length) {
                        e.isShow = false
                        arr.forEach((a) => {
                            if (e.descPath === a.fieldKeyPath) {
                                e.isShow = true
                            }
                        })
                    } else {
                        e.isShow = true
                    }
                })

            customizeList.length &&
                d2.forEach((e, i) => {
                    if (e.childList && e.childList.length) {
                        e.childList.forEach((c) => {
                            if (c.childList && c.childList.length) {
                                c.childList.forEach((cc) => {
                                    customizeList.forEach((a) => {
                                        if (cc.customize && cc.fieldRule.descPath === a.descPath) {
                                            cc.value = a.value
                                        }
                                    })
                                })
                            }
                        })
                    }
                })
            // console.log(customizeList);
            // console.log('customizeList');
            // this.customizeList = customizeList
            // 基本信息
            this.baseInfoList = d2.filter((e) => {
                if (e.name === '基本信息') return e
            })[0].childList
            // 调用递归函数更新父组件的 isShow 属性
            d2.forEach((node) => {
                this.updateParentIsShow(node)
            })
            d2.forEach((e, i) => {
                if (e.childList && e.childList.length) {
                    e.childList.forEach((c) => {
                        if (c.childList && c.childList.length) {
                            if (e.isShow && !!e.display) {
                                this.tabTit.push({
                                    title: e.name,
                                    isShow: e.isShow,
                                    id: i + 1 + ''
                                })
                            }
                        }
                    })
                }
            })

            const uniqueTabTit = []
            const idSet = new Set()
            this.tabTit.forEach((item) => {
                if (!idSet.has(item.id)) {
                    idSet.add(item.id)
                    uniqueTabTit.push(item)
                }
            })
            // console.log(uniqueTabTit)
            this.tabTit = uniqueTabTit
            this.fieldList = d2
            console.log(this.fieldList)
            console.log('this.fieldList')
        },
        // 新增递归函数，用于更新父组件的 isShow 属性
        updateParentIsShow(node) {
            if (node.childList && node.childList.length > 0) {
                let hasTrue = false
                node.childList.forEach((child) => {
                    this.updateParentIsShow(child)
                    if (child.isShow) {
                        hasTrue = true
                    }
                })
                node.isShow = hasTrue
            }
        },
        // 新增递归函数，用于检查 nodeId 是否包含 d.orgId
        checkNodeIdRecursive(node, dOrgId) {
            if (node.nodeId === dOrgId) {
                return true
            }
            if (node.childList && node.childList.length > 0) {
                for (let child of node.childList) {
                    if (this.checkNodeIdRecursive(child, dOrgId)) {
                        return true
                    }
                }
            }
            return false
        },
        async __getDetialData(id) {
            // 获取资产详情
            let res = await this.$Geting(this.$api.getAssetsRegisterById + '?k=' + id)
            if (res.code === '0') {
                let c = res.data.customizeWebDto
                let d = c.businessDto
                // app才能展示所有数据
                if (this.projectTreeData.length) {
                    this.projectTreeData.forEach((node) => {
                        if (this.checkNodeIdRecursive(node, d.orgId)) {
                            this.hasMatchingNodeId = true
                        }
                    })
                }
                this.queryMessage(d.tenantId)
                // 自定义数据
                let customizeList = c.customizeList
                customizeList.length &&
                    customizeList.forEach((item) => {
                        if (item.ctrlType === 'checkbox') {
                            item.value = (item.value && item.value.length && item.value.split(',')) || []
                        }
                        item.descPathArr = item.descPath.split(',')
                    })
                if (d.category === 0) {
                    // 房屋
                    d.houseOrlandDetailWebObj = d.houseDetailWebDto
                } else if (d.category === 1) {
                    // 土地
                    d.houseOrlandDetailWebObj = d.landDetailWebDto
                }

                d.attachmentWebDtoList.forEach((item) => {
                    // 产权
                    if (+item.belongType === 0 && item.attachData.length > 0) {
                        let t = JSON.parse(item.attachData)
                        t.forEach((e) => {
                            e.url = e.fileUrl
                        })
                        this.tableDataCQ = t
                    }
                    // 相关附件
                    if (+item.belongType === 1 && item.attachData.length > 0) {
                        let t = JSON.parse(item.attachData)
                        t.forEach((e) => {
                            e.url = e.fileUrl
                        })
                        this.tableData = t
                    }
                    // 资产图片
                    if (+item.belongType === 2 && item.attachData.length > 0) {
                        this.zctpArr = JSON.parse(item.attachData)
                    }
                })
                d.houseOrlandDetailWebObj.certificateWebDto.issuedDate = d.houseOrlandDetailWebObj.certificateWebDto.issuedDate ? this.__dayjs(d.houseOrlandDetailWebObj.certificateWebDto.issuedDate) : ''
                d.houseOrlandDetailWebObj.certificateWebDto.mortgageEndDate = d.houseOrlandDetailWebObj.certificateWebDto.mortgageEndDate ? this.__dayjs(d.houseOrlandDetailWebObj.certificateWebDto.mortgageEndDate) : ''
                d.houseOrlandDetailWebObj.certificateWebDto.mortgageBeginDate = d.houseOrlandDetailWebObj.certificateWebDto.mortgageBeginDate ? this.__dayjs(d.houseOrlandDetailWebObj.certificateWebDto.mortgageBeginDate) : ''
                // console.log(d)
                // console.log('this.form ')
                let arr = []
                if (this.hasMatchingNodeId) {
                    await this.__getFileList(res.data.fieldTreeWebDtoList, [], customizeList, true)
                } else {
                    arr = await this.__getShowData(d)
                    await this.__getFileList(res.data.fieldTreeWebDtoList, arr, customizeList, false)
                }
                this.form = d
                this.orgObj.name = d.orgName
                console.log(this.form);
                // this.jzmjObj.name = d.houseOrlandDetailWebObj.buildingArea
                this.jcnfObj.name = d.houseOrlandDetailWebObj.builtYear
                this.addressObj.name = d.address
                if (this.form.latitude) {
                    let obj = { lng: this.form.longitude, lat: this.form.latitude, positionType: this.form.positionType || 1 }
                    this.initialPosition = { lng: obj.lng, lat: obj.lat }
                }
                // console.log(this.initialPosition);
                // console.log('this.initialPosition');
            }
        },
        async __getShowData(d) {
            try {
                const res = await this.$Geting(this.$api.getsavePublic + '?id=' + d.typeId + '&tenantId=' + d.tenantId)
                if (res.code === '0') {
                    return res.data
                }
            } catch (error) {
                console.error('请求字段列表出错:', error)
            }
        },
        getMapCoordinate() {
            if (this.form.latitude) {
                let [lng, lat] = [this.form.latitude, this.form.longitude]
                let obj = { lng, lat, positionType: this.form.positionType || 1 }
                // 对数据作坐标转换
                obj = BaiduGaoDeLngLatConvert(obj, this.mapConfig.type, 'location')
                this.initialPosition = { lng: obj.lng, lat: obj.lat }
                this.mapObj = {
                    point: { lng: obj.lng, lat: obj.lat }
                }
                this.$nextTick(() => {
                    this.$refs.mapWrap && this.$refs.mapWrap.handleClick(this.mapObj)
                })
            }
        },
        viewMapClick() {
            this.mapShow = true
            this.$nextTick(() => {
                this.$refs.positionMap && this.$refs.positionMap.handleClick(this.mapObj)
            })
        }
    }
}
</script>

<style lang="less" scoped>
.p-detail-box {
    height: 100vh;
    background: #f5f6f8;
    padding-bottom: 30px;
    overflow: scroll;

    .color86 {
        color: #868b97;
    }

    .my-swipe {
        width: 100vw;
        height: 212px;

        ::v-deep .van-image {
            width: 100%;
            height: 100%;

            img {
                width: 100%;
                height: 100%;
            }
        }
    }

    .bgfff {
        background: #fff;
    }

    .p-title {
        font-size: 17px;
        font-weight: 600;
        color: #171e33;
        margin: 0 0 16px;
    }

    .addr-bg {
        width: 100%;
        height: 67px;
        background: url('../../assets/addrbg.png') no-repeat center/100%;
        position: relative;

        img {
            position: absolute;
            width: 34px;
            height: 34px;
            top: 6px;
            right: 12px;
        }

        .p-addr {
            padding: 12px 0 0 12px;
            margin-bottom: 0;
        }
    }

    .p-addr2 {
        padding: 12px 0 0 12px;
    }

    .flex-bc {
        display: flex;
        align-items: center;
        justify-content: space-between;
    }

    .flex1 {
        flex: 1;
    }

    .p-addr {
        color: #171e33;
        font-size: 14px;
        margin-bottom: 10px;
    }

    .p-t-box {
        padding: 16px 12px;
    }

    .p16 {
        padding: 16px;
    }

    .ptb16 {
        padding: 16px 0;
    }

    .mlr16 {
        margin: 0 16px;
    }

    ::v-deep .new-tabs-box {
        .van-tab {
            flex: none;
            border: 1px solid #c4ccdc;
            margin-left: 10px;
            padding: 6px 12px;
            font-size: 14px;
            height: 32px;
            color: #4c505a;
            border-radius: 4px;
        }

        // .van-tabs__nav {
        //     .van-tab:first-child {
        //         margin-left: 0;
        //     }
        // }

        .van-tabs__nav--line.van-tabs__nav--complete {
            padding-left: 12px;
        }

        .van-tab--active {
            background: #3772ff !important;
            color: #fff !important;
            border-color: #3772ff;
        }

        .van-tabs__wrap {
            position: relative;

            &::after {
                content: '';
                width: 100%;
                position: absolute;
                bottom: 0;
                left: 0;
                border-bottom: 1px solid #3772ff;
            }
        }

        .van-tabs__line {
            background-color: #fff;
            width: 5px;

            &::before {
                content: '';
                position: absolute;
                left: 50%;
                width: 5px;
                height: 5px;
                top: 2px;
                background-color: #fff;
                border-top: 1px solid #3772ff;
                border-bottom: 1px solid #3772ff;
                border-left: 1px solid #3772ff;
                border-right: 1px solid #3772ff;
                transform: rotateZ(45deg) translateX(-50%);
            }
        }
    }

    ::v-deep .van-cell {
        padding: 0 0 12px 0 !important;

        .van-cell__title.van-field__label {
            color: #868b97;
            font-size: 14px;
        }

        .van-field__control {
            font-size: 14px;
            color: #171e33;
            font-weight: 500;
        }
    }

    ::v-deep .is-upload {
        border-radius: 8px;

        .custom-title,
        .file-arrow,
        .custom-tip {
            display: none;
        }

        .van-cell {
            border-radius: 8px;
        }

        .file-tit {
            font-size: 14px;
            color: #171e33 !important;
            padding-left: 16px !important;
        }

        .file-info {
            padding: 16px;
        }
    }

    .item-box {
        padding: 0 12px;

        .s-name {
            font-size: 15px;
            line-height: 18px;
            font-weight: 600;
            padding: 14px 0 10px;
            position: relative;
            z-index: 1;

            &::after {
                content: '';
                width: 60px;
                height: 8px;
                background: linear-gradient(90deg, #3772ff 0%, rgba(245, 246, 248, 0) 100%);
                position: absolute;
                bottom: 12px;
                left: 0;
                z-index: -1;
            }
        }

        .bb1:nth-child(2) {
            border-radius: 8px 8px 0 0;
            padding-top: 16px;
        }
    }

    .item-box1 {
        .bb1:last-child {
            border-radius: 0 0 8px 8px;
            padding-bottom: 6px;

            .van-cell {
                display: none;
            }
        }
    }

    .bb1 {
        padding: 0 12px;
        background: #fff;
        position: relative;
    }

    .disn {
        height: 20px;
    }

    .c-img {
        width: 297px;
        height: 160px;
        background: url('../../assets/no.png') no-repeat center/100%;
        margin: 20px auto 0;
    }

    .c-f {
        font-weight: 500;
        font-size: 14px;
        color: #d8d8d8;
        padding-top: 12px;
        text-align: center;
    }

    .e-item2 {
        margin: 16px 12px 0;
    }

    .e-item {
        background: #ffffff;
        padding: 16px 12px;
        border-radius: 10px;
        font-weight: 500;
        font-size: 14px;

        .e-top {
            color: #868b97;
        }

        .e-txt {
            padding-top: 20px;
            color: #171e33;
        }
    }
}
</style>
